package com.welink.cmp.adapter.api.metadata.query;

import com.welink.cmp.dto.metadata.MetadataIdListQry;
import com.welink.cmp.dto.metadata.MetadataIdQry;
import com.welink.cmp.dto.metadata.router.clientobject.RouterBasicCO;
import com.welink.cmp.dto.metadata.router.clientobject.RouterCO;
import com.welink.cmp.dto.metadata.router.query.RouterListByPageQry;
import com.welink.cmp.meatdata.service.RouterAppService;
import com.welink.common.dto.MultiResponse;
import com.welink.common.dto.PageResponse;
import com.welink.common.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 路由器查询服务API
 *
 * @create
 */
@RestController("/api/router/query")
public class RouterQueryServiceApi {

    @Autowired
    private RouterAppService routerAppService;

    /**
     * [ID查询]查询路由器信息详情
     * @param idQry 主键ID
     * @return Router DTO
     */
    @GetMapping("/rt-item")
    public SingleResponse<RouterCO> queryRouterById(@RequestBody MetadataIdQry idQry){
        RouterCO dto = routerAppService.getRouterById(idQry.getId());
        return SingleResponse.of(dto);
    }

    /**
     * [列表查询]列表查询路由器信息
     * @param listQuery 列表查询指令
     * @return Router DTO列表
     */
    @GetMapping("/rt-list")
    public MultiResponse<RouterCO> listQueryRouter(@RequestBody MetadataIdListQry listQuery){
        List<RouterCO> list = routerAppService.routerListQuery(listQuery);
        return MultiResponse.of(list);
    }

    /**
     * [分页查询]分页查询路由器信息
     * @param pageQry 分页查询指令
     * @return Router DTO分页结果
     */
    @GetMapping("/rt-page")
    public PageResponse<RouterCO> pageQueryRouter(@RequestBody RouterListByPageQry pageQry){
        return routerAppService.routerPageQuery(pageQry);
    }
}